import {login} from '../../api/user'
import {setT,getT,removeT} from '../../api/token'
export default
{
namespaced:true,


    state: {
        tokenn:getT()
    },
    getters: {
    },
    mutations: {
        getToken(state,token){

            state.tokenn=token
            setT(token)
        },
        deleteToken(state){
         state.tokenn=null,
         removeT()
        }
    },
    actions: {

      async setToken(store,user){

        let res =await login(
            user
          )
        //  localStorage.setItem('token',res.data.token)
        // setT(res.data.token)
       store.commit('getToken',res.data.token)
       }

    },
}